import Home from "../view/Home";
import Cate from "../view/Cate";
import Cart from "../view/Cart";
import My from "../view/My";
import Chat from "../view/Chat";
import Fenlei from "../view/Fenlei";
import Orders from '../view/Orders'
import Cartorders from '../view/Cart-orders'
import Index from "../view/Index.js";
import GroupChat from "../view/GroupChat.js";
import Guanli from '../view/Guanli.js'
import Member from '../view/Member.js'
import { Navigate } from "react-router-dom";
import CateList from '../view/CateList.js'
import UseModify from '../view/UseModify.js'




import Home1 from "../pages/Home";
import Login1 from "../pages/Login";
import PC_Login from "../pages/PC_Login";
// import App from "../App.js";
import List from "../pages/List.jsx";
import Test from "../view/Test.js";
export default [
    {
        path: '/login',
        element: <Login1></Login1>
    },
    {
        path: '/',
        element: routerGuard(<Index></Index>),
        children: [
            {
                path: 'home',
                element: <Home></Home>
            },
            {
                path: 'cate',
                element: <Cate></Cate>
            },
            {
                path: 'cart',
                element: <Cart></Cart>,
            },
            {
                path: 'cart-orders',
                element: <Cartorders></Cartorders>,
            },
            {
                path: 'my',
                element: <My></My>

            },
            {
                path: 'groupChat',
                element: <GroupChat></GroupChat>
            },
            {
                path: 'my',
                element: <My></My>
            },
            {
                path: 'chat',
                element: <Chat></Chat>
            },
            {
                path: 'Fenlei',
                element: <Fenlei></Fenlei>
            },
            {
                path: 'Orders',
                element: <Orders></Orders>
            },
            {
                path: 'test',
                element: <Test />
            },
            {
                path: 'usemodify',
                element: <UseModify></UseModify>
            },
            {
                path: '/cateList',
                element: <CateList />
            },
            {
                path:'guanli',
                element:<Guanli></Guanli>
            },
            {
                path:'member',
                element:<Member></Member>
            }
        ]
    },

    { path: '/home1', element: <Home1 /> },
    { path: '/login1', element: <Login1 /> },
    { path: '/pc_login', element: <PC_Login /> },
    { path: '/list', element: <List /> },
]

function routerGuard(params) {
    let token = localStorage.getItem('accessToken')
    if (token) {
        return params
    } else {
        return <Navigate to="/login" />
    }
}
